#ifndef _MODEL_H
#define _MODEL_H

#include "../StdAfx.h"
#include "../file/XmlLoader.h"

struct RotModelDataSt{
    float x;
    float y;
    float z;
};

class cModel {
    
private:
    
    // Propiedades privadas
    
    // Metodos privados
    void UpdateTransform();
    void SetListaVertices();
    void EnableClient();
    void DisableClient();
    void SetTexture();    
    void UpdateFrustum();
    
    //void CreateBuffer(GLfloat listVertex[], ushort listIndexs[]);ç
    void CreateBuffer();
    void CreateBufferFromXML();
    
public:
    
    GLuint m_pTriangleVBO;
    GLuint m_pTriangleIBO;
    int vertexCount;
    int indexCount;
    
    // Parseo de XML
    std::vector<GLuint> m_pCordIdList;
    std::vector<GLuint> m_pTextCoordsIdList;
    std::vector<GLuint> m_pColorsIdList;
    std::vector<GLuint> m_pMatIdsList;
    
    std::vector<GLfloat> m_pVertices;
    std::vector<GLfloat> m_pNormals;
    std::vector<GLfloat> m_pColors;
    std::vector<GLfloat> m_pTexCoords;
    
    std::vector<GLfloat> listXmlVertexBuffer;
    std::vector<ushort> listXmlIndexs;
    
    GLuint m_pTexture;
    
    cXmlLoader *m_xmlLoader;
    
    std::string UVTiling;
    std::string UVOffset;
    
    // Propiedades publicas
    RotModelDataSt RotateModelData;
    
    std::string name;
    int matID;
    int sizeOfBuffer;
    
    // Metodos publicos
    cModel(
        std::vector<GLuint> m_pCordIdList,
        std::vector<GLuint> m_pTextCoordsIdList,
        std::vector<GLuint> m_pColorsIdList,
        std::vector<GLuint> m_pMatIdsList,
        std::vector<GLfloat> m_pVertices,
        std::vector<GLfloat> m_pNormals,
        std::vector<GLfloat> m_pColors,
        std::vector<GLfloat> m_pTexCoords,
        std::string name,
        int matID
    );

    ~cModel();

    void RotateModelInX(float angle);
    void RotateModelInY(float angle);
    void RotateModelInz(float angle);
    void ScaleModel(float x, float y, float z);
    void TranslateModel(float x, float y, float z);
    void LogCreateBuffer(int sizeOfVertice, int elementPerVertex, int sizeOfBuffer);
    
    float GenRadius();
    
    GLuint LoadTexture(char* filename);
    void Scale(float amt);
    void Update(float timeDelta);
    void Draw();

};

#endif // _MODEL_H